﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Model;
using MsDAL;
using System.ComponentModel;
using Components;

namespace ServiceHelper
{
    [DataObjectAttribute]
    public partial class Bas0a01Manager : Bas0a01Base
    {
        private static Bas0a01Manager _entity;

        public static Bas0a01Manager Entity
        {
            get
            {
                if (_entity == null)
                    _entity = new Bas0a01Manager();
                return _entity;
            }
        }

        #region 个人代码
        public string SaveData(Hashtable tb, DataTable dtl, DataTable deldata, string action, string usercode)
        {
            List<SqlApp> lst = new List<SqlApp>();

            Bas0a01 model = null;
            if (dtl == null || dtl.Rows.Count == 0 && "A" == action) return "明细中没有数据，不需要保存！";

            string appstr = Context.GetAppByUserCode(usercode);
            string groupcode = Validation.ToString(tb["groupcode"]);
            string groupname = Validation.ToString(tb["groupname"]);

            if ("M" == action)
            {
                //先删除
                lst.Add(bas0a01Dal.DeleteByGroupcode(groupcode));
            }

            if (null != dtl)
            {
                foreach (DataRow dr in dtl.Rows)
                {
                    model = new Bas0a01();
                    CommonUtil.GetInstance.CopyProperties(model, dr); //复制

                    model.Groupcode = groupcode;
                    model.Groupname = groupname;

                    lst.Add(this.Add(model));
                }
            }

            return CommonManager.Entity.SaveData(lst);
        }

        #endregion
    }
}



